
clear

set matsize 2000

use TimelinePartiesMI_New.dta, clear

gen net=poll_-vote_

gen inet=ipoll_-vote_

**************************************************************************************************************************************************************************************
** SET UP MULTIPLE IMPUTATION ********************************************************************************************************************************************************
**************************************************************************************************************************************************************************************

foreach x of numlist 1/50 { 
gen _`x'_inet=net
replace _`x'_inet = _`x'_ipoll-vote_ if missing(net)
}

drop ae__*_

mi unset

save TimelinePartiesMI_Net.dta, replace

mi import wide, imputed( net = _1_inet _2_inet _3_inet _4_inet _5_inet _6_inet _7_inet _8_inet _9_inet _10_inet _11_inet _12_inet _13_inet _14_inet _15_inet _16_inet _17_inet _18_inet _19_inet _20_inet _21_inet _22_inet _23_inet _24_inet _25_inet _26_inet _27_inet _28_inet _29_inet _30_inet _31_inet _32_inet _33_inet _34_inet _35_inet _36_inet _37_inet _38_inet _39_inet _40_inet _41_inet _42_inet _43_inet _44_inet _45_inet _46_inet _47_inet _48_inet _49_inet _50_inet )

mi register regular vote_
mi xtset, clear 
mi set M = 50

replace daysbeforeED=daysbeforeED/365

replace t_pr=pr*daysbeforeED
replace t_enpp=enpp*daysbeforeED
replace t_partycentric=partycentric*daysbeforeED
replace t_vote=vote*daysbeforeED
replace t_partyold=partyold*daysbeforeED 
replace t_niche=niche*daysbeforeED
replace t_gov=gov*daysbeforeED
replace t_inc=inc*daysbeforeED 

**************************************************************************************************************************************************************************************
** SUPPLEMENTARY ANALYSIS - TABLE S1 (DIRECTIONAL ERRORS) ****************************************************************************************************************************
**************************************************************************************************************************************************************************************

* TIMELINE 
reg net daysbeforeED   
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(1)") title("", "Legislative elections") replace

* TIMELINE + ERROR 
reg net daysbeforeED ipollse
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(2)") title("", "Legislative elections") merge

* TIMELINE + ERROR + PR
reg net daysbeforeED ipollse pr t_pr
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(3)") title("", "Legislative elections") merge

* TIMELINE + ERROR + PR + ENP + SIZE
reg net daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(4)") title("", "Legislative elections") merge

* TIMELINE + ERROR + ENP + PARTY SIZE + PARTY TRAITS
reg net daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc 
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(5)") title("", "Legislative elections") merge

* INTERPOLATED 
reg inet daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc 
*outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(7, Interpolated)") title("", "Legislative elections") merge

* INTERPOLATED (PARTY CONTROLS)
reg inet daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc, absorb(_couXpar_)
*outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(8*, Interpolated, party controls)") title("", "Legislative elections") merge

* MULTIPLE IMPUTATION 
mi estimate, post dots: reg net daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(6, Multiply imputed)") title("", "Legislative elections") merge
mibeta net daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc

* MULTIPLE IMPUTATION (PARTY CONTROLS)
mi estimate, post dots: reg net daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc, absorb(_couXpar_)
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(7*, Multiply imputed, party controls)") title("", "Legislative elections") merge
mibeta net daysbeforeED ipollse pr t_pr enpp t_enpp vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc, absorb(_couXpar_)

* TIMELINE + ERROR + ENP + PARTY SIZE + PARTY TRAITS
reg net daysbeforeED ipollse vote_ t_vote partyold t_partyold niche t_niche gov_ t_gov inc t_inc 
outreg using EJPR_TabS1, se bdec(3) sigsymb(*,**,***) starlevels(5 1 .1) summstat(N \ r2 \ r2_a) summtitle(N \ R-squared \ Adjusted R-squared) ctitle("", "(8)") title("", "Legislative elections") merge

erase TimelinePartiesMI_Net.dta

